package cn.lzy.demo.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @Description
 * @Author lzy
 * @Date 2023/12/27 23:10
 * @Version
 **/
@Repository
public class AccountDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     * 加钱
     * @param username
     * @param money
     */
    public void addMoney(String username, Double money) {
        jdbcTemplate.update("update account set money = money + ? where username = ?", money, username);
    }


    /**
     * 减钱
     * @param username
     * @param money
     */
    public void minusMoney(String username, Double money) {
        jdbcTemplate.update("update account set money = money - ? where username = ?", money, username);
    }
}
